home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
util
/
misc
/
OpenLibCounter.lha
/
OpenLibraryCounter.doc
< prev
Wrap
Text File
|
1997-09-22
|
9KB
|
261 lines
OpenLibraryCounter V1.13 (1997-Sep-22)
Distribution conditions
~~~~~~~~~~~~~~~~~~~~~~~
This program is Copyright ©1996-1997 by Peter Mattsson. It may be
distributed freely under the condition that no profit is gained from
its distribution.
Permission is granted to distribute this package by Bulletin Board
systems or network sites, under the condition no fee is charged on
downloading it. Permission is also granted to put this package on
Aminet CDs. Other CD compilers have to contact the author. Permission
is also granted to computer magazines to put this package on their
coverCDs/coverdisks, under the condition the author is sent a free
copy of the CD-edition (if available) of the magazine where this
package is included.
All files that are part of this package have to be distributed
together and none of them may be changed in any way other than
archiving or crunching.
This program is distributed as Freeware.
Disclaimer
~~~~~~~~~~
This package is provided "as is" without warranty of any kind. The
author assumes no responsibility or liability whatsoever for any
damage or dataloss caused by using this package.
Introduction
~~~~~~~~~~~~
OpenLibraryCounter will tell you what libraries are opened and how
many times they are opened.
This may be useful in order to determine what libraries in your
overcrowded LIBS: actually are used.
It can also be amusing, did you know there are programs trying to
open exec.library? :) I think it was a Blitz Basic program that
caused that entry.
Requirements
~~~~~~~~~~~~
OpenLibraryCounter requires:
* An Amiga or an Amiga emulator ;)
* Kickstart V37+
* 68000+
* A LIBS: crowded with libraries ;)
* PhxAss or a compatible assembler if you want to assemble the
sourcecode
OpenLibraryCounter has been tested on my computer, an Amiga 1200 with
Kickstart 3.1, Blizzard 1260, 20MB memory, 2.1GB SCSI harddisk, 4x
CD-ROM, 210MB IDE harddisk, an extra diskdrive, a Wico Super Threeway
joystick, a DATIC mouse and an Algonet mousepad.
It has also been tested on an friends Amiga 4000 with Kickstart 3.1,
Powerchanger 040-28, 18MB, GVP Spectrum 28/24, Trumphcard Pro, 1GB
SCSI, 420MB IDE, 8x CD-ROM and a Commodore A500 mouse running on an
Algonet mouse pad.
Installation
~~~~~~~~~~~~
Copy the OpenLibraryCounter executable wherever you want, preferrable
somewhere in your path. I keep mine in C:.
If you want to install the documentation, copy it to HELP:English/ or
wherever you want.
If you want to start OpenLibraryCounter every time you boot your
computer, insert the following line in your startup-sequence/
user-startup:
Run <NIL: >NIL: OpenLibraryCounter
Don't put it in the startup-sequence if you don't know what you are
doing though! Putting it in user-startup is safer but won't catch
libraries used by programs started in the startup-sequence. If you
put it in the startup-sequence make sure it is started after
PatchControl or any similar program. And it should of course be
started after SetPatch.
Usage
~~~~~
OpenLibraryCounter L=LOGFILENAME,I=SAVEINTERVAL
LOGFILENAME: This is the file where the list of libraries is saved.
The default is "S:LibraryOpenCount".
SAVEINTERVAL: This is the number of libraries to be opened between
each save of the library list. Default is 500.
To find out what libraries is really used in your LIBS: there are two
ways:
1. Start OpenLibraryCounter and then run every program on your
harddisk. Then quit OpenLibraryCounter and check the log file to
see what libraries was opened. This is not 100% safe though, as
some programs only opens certain libraries when you activate a
certain function in the program.
2. Put OpenLibraryCounter in your startup-sequence/user-startup and
use your computer as normal during a month or two. Now you can be
quite sure that all libraries not mentioned in the log file is not
used.
In both cases I recommend that you don't actually delete unused
libraries. Put them in another directory instead and see if any
program complains. After some time, maybe a month, you can probably
delete them.
To quit OpenLibraryCounter, send it a CTRL-C signal.
The log file format
~~~~~~~~~~~~~~~~~~~
The log file is saved in ASCII for easy viewing. Every line in the
file starts with the name of the library, followed by a TAB character
(ASCII code 9), followed by the number of times the library has been
opened, followed by a linefeed (ASCII code 10).
Do not edit this file if you don't know exactly what you are doing!
However using the Sort command to sort the log file is generally
safe. Just make sure OpenLibraryCounter is not running when you sort
the file.
How does it work
~~~~~~~~~~~~~~~~
OpenLibraryCounter will start with loading in the logfile and setting
up a message port. Then it patches OpenLibrary() in exec.library. The
patch will allocate a message and copy the library name to this
message every time a library is successfully opened. The message is
then sent to OpenLibraryCounter that will update its list of
libraries and free the message. Every now and then the list of
libraries is saved to the logfile.
When OpenLibraryCounter receives a CTRL-C signal it will first of all
save the libraries list. Then OpenLibraryCounter will remove the
OpenLibrary() patch. Then it waits 10 seconds to be really sure that
no task still executes a OpenLibrary() call. Then all messages that
might have appeared at the message port are removed and freed. Then
the program exits. This is not 100% safe, but it is close.
Note that if another program patches OpenLibrary() after
OpenLibraryCounter is started and you then exit OpenLibraryCounter,
this might lead to unexpected behaviour if you are not using a
program like PatchControl (part of the MCP archive).
The sourcecode
~~~~~~~~~~~~~~
The sourcecode of OpenLibraryCounter is included so you can see what
you are running on your computer. Unfortunately it is not very well
commented, it is hardly commented at all.
If you want to use parts of my sourcecode in your own programs, feel
free to do so. But please contact me and tell me if you do use it.
Bugs/limitations
~~~~~~~~~~~~~~~~
Currently OpenLibraryCounter suffers from the following bugs and
limitations:
* Sometimes the log file gets corrupted. I don't know why yet. When
the log file gets corrupted some entries will be lost next time
OpenLibraryCounter is started. If somebody finds a foolproof way to
reproduce this bug, please contact me.
* Library names is treated as illegal if they are longer than 1024
characters, including their path.
* Library names is also treated as illegal if there is a TAB
character in the library name. Shouldn't cause any problems.
* The removal of the patch is not 100% safe. It is very close though,
I've never had a crash when quitting OpenLibraryCounter.
* The counter for each library is limited to a 32-bit unsigned
integer. That means if a library is opened more than 4.294.967.295
times, the counter will wrap to 0. In practical terms it means that
if a library is opened 5,1 times per second (as dos.library is on
my computer) it will take more than 26 years before the counter
wraps.
History
~~~~~~~
1996-May-05 Project started.
1996-May-12 V1.0 Not publicly released.
1996-May-14 V1.01 Fixed race condition problems.
Not publicly released.
1997-Sep-09 V1.1 All recursive calls were removed to save stack
space.
Logfilename and save interval is now user
definable.
A couple of potential bugs were removed.
Removal of the patch is safer.
Not publicly released.
1997-Sep-09 V1.11 The OpenLibrary() patch uses less stack space.
Delimiter character in log file changed from
SPACE to TAB.
First public release.
1997-Sep-12 V1.12ß OpenLibraryCounter now should only require a
68000 processor. As a bonus the executable got
smaller in the process.
Not publicly released.
1997-Sep-22 V1.13 The reading of the log file is made much safer.
OpenLibraryCounter shouldn't crash now if the log
file is corrupted.
Second public release.
Todo list
~~~~~~~~~
* Make the removal of the patch even safer.
* Store what programs open what libraries.
* Store the library names in a binary search tree internally to cut
search times.
Contact address
~~~~~~~~~~~~~~~
Send bug reports, suggestions, magazines, PowerUP cards, Ferraris,
etc, etc, to:
E-mail: petermat@algonet.se (preferred way of communication)
Snail-mail:
Peter Mattsson
Vinberga 7
S-373 02 Ramdala
Sweden
Homepage URL: http://www.algonet.se/~petermat/
Copyrights
~~~~~~~~~~
MCP is Copyright ©1994-1997 by ALiENDESiGN.